#!/bin/bash

# Формирование изображений диаграм АСД для основных операций SBL

dir=doc/tree
png=fuze

if [ -d $dir/$png ]
then
    echo $dir/$png exists, cleaning...
    #rm -rf $dir/$png/*.png
else
    mkdir $dir
    mkdir $dir/$png
fi

echo Starting to create diagrams...

for file in data/grammar/*.fuze
do
    echo ${file}
    fbname=$(basename "$file" | cut -d. -f1)
    bin/simodo-grammatize -S ${file} -s test/tmp/${fbname}.dot
    if [ -e test/tmp/${fbname}.dot ]
    then
        dot -Tpng test/tmp/${fbname}.dot -o${dir}/$png/${fbname}.png
    fi
done

rm -rf test/tmp/*.dot
